package com.lfs.market.controller.admin;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lfs.market.model.R;
import com.lfs.market.model.dto.SystemProductOrderPageDto;
import com.lfs.market.model.entity.Orders;
import com.lfs.market.model.vo.AdminOrderDetailVo;
import com.lfs.market.service.OrdersService;
import com.lfs.market.service.ProductOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/product/order")
@SaCheckLogin
@SaCheckRole(value = {"admin"})
public class ProductOrderAdminController {
    @Autowired
    private ProductOrderService productOrderService;

    @Autowired
    private OrdersService ordersService;

    @GetMapping("/page")
    public R<Page<Orders>> getProductOrderList(SystemProductOrderPageDto dto) {
        Page page = productOrderService.getProductOrderList(dto);
        return R.ok(page);
    }

    /**
     * 根据订单号查询订单信息
     *
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public R<AdminOrderDetailVo> getDetail(@PathVariable("id") String id) {
        AdminOrderDetailVo map = ordersService.getOrderDetail(id);
        return R.ok(map);
    }

    @GetMapping("/page/evaluate")
    public R<Page> getProductOrderEvaluateList(SystemProductOrderPageDto dto) {
        Page page = productOrderService.getProductOrderEvaluateList(dto);
        return R.ok(page);
    }
}
